package com.chinadci.smartcommunitysystembackstage.mapper;

import com.chinadci.smartcommunitysystembackstage.entity.ScsPay;
import com.chinadci.smartcommunitysystembackstage.entity.ScsPayType;
import com.chinadci.smartcommunitysystembackstage.entity.ScsPhone;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chinadci.smartcommunitysystembackstage.entity.ScsPositionType;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
public interface ScsPhoneMapper extends BaseMapper<ScsPhone> {

    //显示所有便民电话
    @Select("select * from scs_phone where p_name like #{name}")
    @Results({
            @Result(id = true,column = "p_id",property = "pId"),
            @Result(column = "p_phone",property = "pPhone"),
            @Result(column = "p_name",property = "pName"),
            @Result(column = "p_sex",property = "pSex"),
            @Result(column = "p_age",property = "pAge"),
            @Result(column = "p_position",property = "type",many =@Many(select = "Select"))
    })
    List<ScsPhone> Find(String name);

    @Select("select * from scs_position_type where pt_id=#{pt_id}")
    List<ScsPositionType> Select(int id);

    //显示所有便民电话
    @Select("select * from scs_phone where p_id=#{id}")
    @Results({
            @Result(id = true,column = "p_id",property = "pId"),
            @Result(column = "p_phone",property = "pPhone"),
            @Result(column = "p_name",property = "pName"),
            @Result(column = "p_sex",property = "pSex"),
            @Result(column = "p_age",property = "pAge"),
            @Result(column = "p_position",property = "type",many =@Many(select = "Select"))
    })
    List<ScsPhone> Finds(int id);
}
